import axios from '@/api/request'

const api = {
  uploadFile (body) {
    return axios.upload('file/images', {
      filePath: body.filePath,
      name: 'filePath',
      custom: { needLoading: true },
    })
  },
  home () {
    return axios.get('wechat/refreshLogin')
  },
  wxMpLogin (params) {
    return axios.get('wechat/mini/login', { params, custom: { needLoading: true } })
  },
  certificate (params) {
    return axios.get(`loginUser/certificate`, { params, custom: { needLoading: true } })
  },
  getDict (params) {
    return axios.get('dict', { params })
  },
  // 建议
  getAdviceList (params) {
    return axios.get('advice', { params })
  },
  getAdviceDetail (params) {
    return axios.get(`advice/${params.id}`, { params, custom: { needLoading: true } })
  },
  getAdviceProcess (params) {
    return axios.get(`advice/${params.id}/process`, { params, custom: { needLoading: true } })
  },
  adviceAppraise (body) {
    return axios.post(`advice/${body.id}/appraise`, body, { custom: { needLoading: true } })
  },
  adviceAccept (params) {
    return axios.get(`advice/${params.id}/accept`, { params, custom: { needLoading: true } })
  },
  adviceCancelAccept (params) {
    return axios.delete(`advice/${params.id}/accept`, { params, custom: { needLoading: true } })
  },
  // 查询代表
  searchUser (params) {
    return axios.get(`advice/search/${params.value}`)
  },
  addAdvice (body) {
    return axios.post(`advice`, body, { custom: { needLoading: true } })
  },

  // 活动
  getActivityList (params) {
    return axios.get('activity', { params })
  },
  getActivityDetail (params) {
    return axios.get(`activity/${params.id}`, { params, custom: { needLoading: true } })
  },
  activityNext (body) {
    return axios.post(`activity/join`, body, { custom: { needLoading: true } })
  },

  // 待办
  getTodoList (params) {
    return axios.get('todoList', { params })
  },
  addTodo (body) {
    return axios.post('todoList', body, { custom: { needLoading: true } })
  },
  todoComplete (body) {
    return axios.put(`todoList/complete/${body.id}`, body, { custom: { needLoading: true } })
  },
  todoCancel (body) {
    return axios.put(`todoList/cancel/${body.id}`, body, { custom: { needLoading: true } })
  },
  getTodoDetail (params) {
    return axios.get(`todoList/${params.id}`, { params, custom: { needLoading: true } })
  },

  // 调研
  getVoteList (params) {
    return axios.get('vote', { params })
  },
  getVoteStart (params) {
    return axios.get(`vote/start/${params.id}`, { params, custom: { needLoading: true } })
  },
  getVoteDetail (params) {
    return axios.get(`vote/join/${params.id}`, { params, custom: { needLoading: true } })
  },
  sumbitVote (body) {
    return axios.post(`/vote/ticket`, body, { custom: { needLoading: true } })
  },

  // 学习
  getLearnList (params) {
    return axios.get('learn', { params })
  },
  getLearnDetail (params) {
    return axios.get(`learn/${params.id}`, { params })
  },

  // 个人信息
  getUserInfo () {
    return axios.get('user/detail')
  },
}

export default api
